package com.example.test19_2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btn1 = (Button) findViewById(R.id.btn1);
        Button btn2 = (Button) findViewById(R.id.btn2);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent1 = new Intent();
                intent1.setAction("com.example.test19_2.MY_BROADCAST");
                intent1.setComponent(new ComponentName("com.example.test19_2",
                        "com.example.test19_2.AnotherBroadcastReceiver"));
                sendBroadcast(intent1);
            }
        });
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent2 = new Intent();
                intent2.setAction("com.example.test19_1.MY_BROADCAST");
                intent2.setComponent(new ComponentName("com.example.test19_1",
                        "com.example.test19_1.MyBroadcastReceiver"));
                sendBroadcast(intent2);
            }
        });
    }
}